import requests

class HandleRequest():
    """
    定义一个封装类
    """
    proxies = {
        "http": "http://127.0.0.1:8888",
        "https": "http://127.0.0.1:8888"
    }

    def __init__(self):
        self.res = requests.Session()

    def close(self):
        self.res.close()

    def sendRequests(self, method, url, data, headers=None, is_json=False):
        if method.lower() == "post":
            if is_json:
                return self.res.post(url, json=data, headers=headers, proxies=None)
            else:
                return self.res.post(url, data=data, headers=headers, proxies=None)
        elif method.lower() == "get":
            return self.res.get(url, params=data, headers=headers, proxies=None)
        else:
            self.res = None
            print("输入请求不支持")


if __name__ == "__main__":
    pass
